
import TaskStep from '@/components/taskStep.vue';

import apiMixin from '@/mixin/apiMixin';
import taskMixin from '@/mixin/taskMixin';

import uilts from '@/utils/index';
export default {
    mixins: [apiMixin,taskMixin],
    data() {
        return {
            loading: false,
            taskSteps: [],
            uploadBids: [],
            linkConfig: {
                name: "",
                // title: '',
                // not_allow_edite_title: false,
                deadline_time: "",
                deadline_time_allow_edit: false,
                limited_time: "",
                limited_time_allow_edit: false,
                limited_time_approve:"",
                limited_time_approve_allow_edit: false,
                limited_os: [],
                limited_os_allow_edit: false,
            }
        }
    },
    mounted() {
        this.init();
    },
    methods: {
        init() {
            let id = this.$route.query.id;
            if (id) {
                this.getSystemTeplateDetailApi();
            }
        },
        getSystemTeplateDetailApi() {
            let _self = this;
            let id = this.$route.query.id;
            this.comResquest(this.request.getSystemTeplateDetail,(res)=>{
                console.log(res);
                let { result } = res;
                _self.taskSteps = result.custom_steps;
                _self.linkConfig = result;
            },{
                id,
                load: true
            });
        },
        postSystemTeplateDetailApi() {
            let id = this.$route.query.id;
            if(!(this.linkConfig.name && this.linkConfig.limited_os && this.linkConfig.limited_os.length>0)){
                that.$message.warning("请输入模板名称和设备");
                return;
            }
            let data = uilts.simpleCopy(this.linkConfig);
            data.custom_steps = JSON.stringify(this.taskSteps);
            data.bids = this.uploadBids;
            data.id = id;
            let _self = this;
            this.comResquest(this.request.postSystemTeplateDetail,(res)=>{
                _self.$message.success('操作成功');
                _self.init();
            },{
                id,
                update_data: data,
                bids: this.uploadBids
            });
        }
    },
    components:{
        TaskStep
    },
}